package com.smh.yunpicturebackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.smh.yunpicturebackend.api.aliyunai.model.CreateOutPaintingTaskResponse;
import com.smh.yunpicturebackend.pojo.domain.Picture;
import com.smh.yunpicturebackend.pojo.dto.picture.*;
import com.smh.yunpicturebackend.pojo.vo.picture.PictureVO;

import java.util.List;

/**
 * @author shiminghui
 * @description 针对表【picture(图片)】的数据库操作Service
 * @createDate 2025-06-19 23:38:23
 */
public interface PictureService extends IService<Picture> {

    /**
     * 上传图片
     *
     * @param inputSource
     * @param pictureUploadRequest
     * @return
     */
    PictureVO uploadPicture(Object inputSource, PictureUploadRequest pictureUploadRequest);

    /**
     * 获取查询条件
     *
     * @param pictureQueryRequest 查询请求参数
     * @return 查询条件
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);

    /**
     * 获取图片信息
     *
     * @param picture 图片
     * @return
     */
    PictureVO getPictureVO(Picture picture);

    /**
     * 获取图片分页信息
     *
     * @param picturePage
     * @return
     */
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage);

    /**
     * 校验图片
     *
     * @param picture
     */
    void validPicture(Picture picture);

    /**
     * 图片审核
     *
     * @param pictureReviewRequest
     */
    void doPictureReview(PictureReviewRequest pictureReviewRequest);

    /**
     * 填充审核参数
     *
     * @param picture
     */
    void fillReviewParams(Picture picture);

    /**
     * 批量抓取和创建图片
     *
     * @param pictureUploadByBatchRequest
     * @return 成功创建的图片数
     */
    Integer uploadPictureByBatch(
            PictureUploadByBatchRequest pictureUploadByBatchRequest
    );

    /**
     * 获取图片列表(走缓存)
     *
     * @param pictureQueryRequest 查询请求参数
     * @return 图片列表
     */
    @Deprecated
    Page<PictureVO> listPictureByPageWithCache(PictureQueryRequest pictureQueryRequest);

    /**
     * 删除图片
     *
     * @return 删除成功
     */
    boolean deletePictureFiles(List<Picture> pictures);

    /**
     * 获取所有过期图片的URL
     *
     * @param expiredPictures 过期的图片列表
     */
    List<String> getAllPictureUrls(List<Picture> expiredPictures);

    /**
     * 删除图片
     *
     * @param pictureId pictureId
     */
    void deletePicture(long pictureId);

    /**
     * 校验权限
     *
     * @param picture 图片
     */
    void checkPictureAuth(Picture picture);

    /**
     * 清理图片文件
     *
     * @param oldPicture oldPicture
     */
    void deletePictureFile(Picture oldPicture);

    /**
     * 编辑图片
     *
     * @param pictureEditRequest 图片编辑请求
     */
    void editPicture(PictureEditRequest pictureEditRequest);

    /**
     * 根据主色调查询图片
     *
     * @param spaceId
     * @param picColor
     * @return
     */
    List<PictureVO> searchPictureByColor(Long spaceId, String picColor);

    /**
     * 批量修改图片数据
     *
     * @param pictureEditByBatchRequest
     */
    void editPictureByBatch(PictureEditByBatchRequest pictureEditByBatchRequest);

    /**
     * 创建图片扩展任务
     *
     * @param createPictureOutPaintingTaskRequest
     * @return
     */
    CreateOutPaintingTaskResponse createPictureOutPaintingTask(CreatePictureOutPaintingTaskRequest createPictureOutPaintingTaskRequest);
}
